<template>
    <!-- 页面头部 -->
    <HomePageHead></HomePageHead>

    <HomePageNavigation></HomePageNavigation>
    <!-- 广告位 1 -->
    <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>

    <!-- 面包屑导航 -->
    <div class="breadcrumb">
        <div class="inner">
            <span class="location">当前位置:</span>
            <el-breadcrumb :separator-icon="ArrowRight">
                <el-breadcrumb-item>
                    <NuxtLink to="/">首页</NuxtLink>
                </el-breadcrumb-item>
                <el-breadcrumb-item>
                    {{ newsDetail.con_title }}
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
    </div>

    <!-- 资讯列表 -->
    <div class="newsDetail">
        <div class="inner">
            <div class="innerDetail">
                <div class="headImg"></div>
                <div class="innerDetail1">
                    <div class="leftBottom" v-html="newsDetail.content"></div>
                </div>
                <div class="footImg"></div>
            </div>
            <div class="innerLeft">
                <ul>
                    <li>
                        导航列表
                    </li>
                    <li v-for="(item, index) in bottomMenu" :key="index">
                        <NuxtLink :to="`/about/${item.name_pinyin}/index.html`" :title="item.name"
                            v-if="item.id == pageId && item.id != 7" class="active">
                            {{ item.name }}
                        </NuxtLink>
                        <NuxtLink :to="`/about/${item.name_pinyin}/index.html`" :title="item.name"
                            v-else-if="item.id != pageId && item.id != 7">
                            {{ item.name }}
                        </NuxtLink>
                    </li>
                </ul>
            </div>
            <div style="clear: both;"></div>
        </div>
    </div>

    <!-- 广告位 2 -->
    <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>

    <!-- 页面底部 -->
    <HomeFoot1></HomeFoot1>
</template>

<script setup>
//1.页面依赖 start ---------------------------------------->
import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
import { ArrowRight } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue';

//获得跳转过来的id
const route = useRoute();
//获得当前的完整路径
const fullPath = route.path;
//拆分，取出来中间这一段，然后提取数字部分
const segments = fullPath.split('/'); 
const targetSegment = segments[2]; 
//const numberPart = targetSegment.match(/\d+$/)?.[0]; 

let articleId;
let pageId;
//通过导航路径反向查询导航id
const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
    method: 'GET',
    query: {
        'foot_pinyin': targetSegment,
    },
});
if(getRouteId.code == 200){
    articleId = getRouteId.data.id;
    pageId = getRouteId.data.id;
}else{
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    console.log("错误位置：通过url路径查询导航池id")
    console.log("后端错误反馈：",getRouteId.message)
    console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
}

//1.页面依赖 end ---------------------------------------->

//2.页面数据 start ---------------------------------------->
//广告列表
let adImg1 = ref([]);
let adImg2 = ref([]);

//获取详情
const newsDetail = ref({})
async function getPageData() {
    const mkdata = await requestDataPromise('/web/getWebsiteFooterCategoryInfo', {
        method: 'GET',
        query: {
            'fcat_id': articleId,
            'type': '0'
        },
    });
    console.log('newsDetail.value', mkdata.data);

    newsDetail.value = mkdata.data;
    console.log('newsDetail.value', newsDetail.value);

}
getPageData();

//获得底部导航
const bottomMenu = ref([]);
async function getPageMenu() {
    const mkdata = await requestDataPromise('/web/getWebsiteFooterCategory', {
        method: 'GET',
        query: {},
    });
    bottomMenu.value = mkdata.data;
}
getPageMenu();
//2.页面数据 end ---------------------------------------->
//4.设置seo信息 start---------------------------------------->
//4.1 设置seo信息
const setData = await requestDataPromise('/web/getWebsiteFootInfo', {
    method: 'GET',
    query: {},
});

let seoTitle = setData.data.website_head.title;
let seoDescription = setData.data.website_head.description;
let seoKeywords = setData.data.website_head.keywords;
let seoSuffix = setData.data.website_head.suffix;
let seoName = setData.data.website_head.website_name;

useSeoMeta({
    title: seoTitle + "_" + seoSuffix,
    meta: [
        { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
        { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
    ]
});
//4.设置seo信息 end---------------------------------------->

onMounted(async () => {
    //从客户端获取行政职能部门 加快打开速度
    const { $webUrl, $CwebUrl } = useNuxtApp();
    //广告1
    let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_page_0001`
    const responseAd1 = await fetch(url, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd1 = await responseAd1.json();
    adImg1.value = resultAd1.data[0];

    //广告2
    let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_page_0002`
    const responseAd2 = await fetch(url2, {
        headers: {
            'Content-Type': 'application/json',
            'Userurl': $CwebUrl,
            'Origin': $CwebUrl
        }
    });
    const resultAd2 = await responseAd2.json();
    adImg2.value = resultAd2.data[0];
})

</script>

<style lang="less" scoped>
//导航条
.breadcrumb {
    width: 1200px;
    margin: 0 auto;
    height: 22px;
    padding-bottom: 40px;
    margin-top: 40px;
    margin-bottom: 60px;
    border-bottom: 1px solid #d9d9d9;
    font-family: Microsoft YaHei, Microsoft YaHei;
    font-weight: 400;
    font-size: 20px;
    color: #666666;
    line-height: 23px;
    text-align: left;
    font-style: normal;
    text-transform: none;

    .el-breadcrumb::v-deep {
        display: inline-block;
        vertical-align: -4px;
    }

    /deep/.el-breadcrumb__inner a,
    /deep/.el-breadcrumb__inner.is-link {
        color: #666666;
        font-weight: 400;
        text-decoration: none;
        transition: var(--el-transition-color);
    }

    span {
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: 400;
        font-size: 20px;
        color: #666666;
        line-height: 23px;
        text-align: left;
        font-style: normal;
        text-transform: none;
    }

    span:hover {
        color: #666666;
    }

    .location {
        margin-right: 20px;
        width: 100px;
        height: 22px;
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: 400;
        font-size: 20px;
        color: #666666;
        line-height: 23px;
        text-align: left;
        font-style: normal;
        text-transform: none;
    }
}

// 资讯列表
.newsDetail {
    width: 100%;
    // height: 1400px;
    // margin-bottom: 70px;

    .inner {
        width: 1200px;
        font-size: 16px;
        position: relative;

        .innerDetail {
            width: 1080px;
            margin: 0 auto;
            margin-bottom: 60px;

            .headImg {
                width: 1086px;
                height: 10px;
                background: url("../../../public/special/head11.png") no-repeat 100% 100%;
            }

            .footImg {
                width: 1086px;
                height: 7px;
                background: url("../../../public/special/foot01.png") no-repeat 100% 100%;
            }

            .innerDetail1 {
                width: 1086px;
                margin: 0 auto;
                padding: 30px 50px 40px;
                box-sizing: border-box;
                border-left: 1px solid #DBBE9E;
                background: url("../../../public/special/mid01.png") repeat-y 100% 100%;
            }

            .leftBottom::v-deep {
                font-size: 16px;
                line-height: 40px;
            }
        }



        .innerLeft {
            width: 279px;
            position: absolute;
            top: 3px;
            left: -155px;

            // .rightMenuTitle {
            //     width: 279px;
            //     height: 69px;
            //     font-size: 22px;
            //     font-weight: bold;
            //     line-height: 58px;
            //     text-align: center;
            //     color: #fff;
            //     background: url("../../../../public/special/projectMoreTitle.png") no-repeat;
            //     margin-bottom: 30px;
            // }

            ul {
                li {
                    a {
                        display: inline-block;
                        width: 144px;
                        height: 60px;
                        line-height: 60px;
                        text-align: center;
                        background-color: #F4F4F4;
                        border-top: 1px #fff solid;
                        font-family: Microsoft YaHei, Microsoft YaHei;
                        font-weight: 400;
                        font-size: 16px;
                        color: #000000;
                    }
                }

                li:nth-child(1) {
                    width: 144px;
                    height: 60px;
                    line-height: 60px;
                    text-align: center;
                    background-color: #F4F4F4;
                    border-top: 1px #fff solid;
                    font-family: Microsoft YaHei, Microsoft YaHei;
                    font-weight: 400;
                    font-size: 16px;
                    color: #a01c0e;
                }

            }

            .active {
                // border-left: 0;
                // border: 1px solid #028E21;
                background: #a01c0e;
                color: #fff;
            }
        }
    }
}
</style>